The present invention relates generally to computer input/output adapters, and specifically to how such an adapter implements memory protection.
FIG. 1 is a schematic diagram illustrating a method of communication in a computing system between a conventional software application 10 and a local network 11, using an input/output (I/O) adapter 16, as is known in the art. As is shown, one of the ways conventional software application 10 communicates with local network 11, as well as with other system elements, is by using a part of an operating system (OS) 12 termed a kernel 14. The kernel acts as an interface between application 10 and I/O adapter 16. For each I/O operation, kernel 14 makes, inter alia, data copies and context switches as required to access the I/O adapter.
In the communication method illustrated by FIG. 1, application 10 uses a kernel call when interfacing with I/O adapter 16. Operating system 12 acts as a trusted agent in translating the kernel call to a corresponding physical address used by the I/O adapter to access local network 11. In other words, the operating system is responsible for ensuring that the specific application, and only the specific application, is able to access the correct physical address, so ensuring that conflicts are avoided.
As computing speeds have increased, the OS-based interface between application and I/O adapter has become a bottleneck, particularly for networked systems, and alternative, higher-speed architectures for interfacing between high-performance network hardware and a computing system have been suggested. One such alternative architecture is described in xe2x80x9cVirtual Interface Architecturexe2x80x9d (VIA) specification version 1.0, published by Compaq Computer Corporation et al., which is incorporated herein by reference.
FIG. 2 is a schematic illustration of such an alternative architecture. The architecture uses a more direct connection between software application 10 and I/O adapter 16 than that shown in FIG. 1, whereby the application interfaces with I/O adapter 16 without the mediation of the operating system. There is a dedicated address 24, or window, assigned in a memory of I/O adapter 16, termed a xe2x80x9cdoorbell,xe2x80x9d through which application 10 communicates with the I/O adapter. Other applications are assigned their own corresponding doorbells. Doorbells are mapped into different pages (typically 4 KB segments) of memory space in order to allow the operating system to maintain protection. In this higher-speed architecture, I/O adapter 16 translates a virtual address 22 provided by the application when it communicates via the doorbell into a physical address which is used to access a system memory 18. The I/O adapter handles the address protection that was previously performed by the operating system, by using a protection tag 20, as described in more detail below.
Appendix C of the VIA specification describes an example of a hardware model of a Virtual Interface Network Interface Controller (VI NIC), which performs the general function of I/O adapter 16 shown in FIG. 2. As explained in the appendix, the VI NIC copies data from system memory 18, inter alia, to a network medium in a transmit phase, and from the medium to memory in a receive phase. In order to perform its tasks of addressing the memory non-contentiously, the VI NIC generates a configurable translation and protection table (TPT) 26 of a given size. The table is used as a look-up table when the NIC translates from a virtual address 22 generated by an application to a corresponding physical address 28. The table comprises ordered pairs of physical memory addresses and a protection tag for each respective address. The tag is generated for each application by the operating system, and the tag is then used to ensure that the physical address is only accessible to a process using the protection tag of the address. Because the TPT has a fixed size, the tag generated may need to be truncated, depending on the number and size of the memory addresses, so that there is a finite chance that a second application will be able to access the physical address being protected.
It is an object of some aspects of the present invention to provide methods and apparatus for ensuring fully non-contentious addressing between a plurality of applications and a memory.
It is a further object of some aspects of the present invention to provide methods and apparatus for ensuring address protection using a hardware-defined key.
In some preferred embodiments of the present invention, a computer application running on a computer system communicates directly with an I/O hardware adapter in the system. During an initialization process for the application, operating system (OS) software which is running on the computer system assigns a register in the I/O adapter to the application. The register is dedicated to the application, and is protected by the operating system of the computer from access by other applications. Also during the initialization, a protection block, specific to the application, is constructed within a memory space of the I/O adapter used by the application. The protection block stores a number key corresponding to a physical address of the register. A data buffer in a memory of the computer system is allocated to the application, and at the end of the initialization process, a xe2x80x9chandlexe2x80x9d associated with the data buffer""s address is created and returned by the OS to the application.
During operation of the application, the application writes commands via the dedicated register on the I/O adapter. Each such command includes a virtual address pointer to the data buffer, together with the handle. The handle is used by the I/O adapter as a pointer to the protection block specific to the application. The I/O adapter adds a key to the command, the key depending on the address of the register through which the command is written. The added key and the key in the protection block are compared, and if the keys match, the command is allowed to execute. If the keys do not match, command execution is denied. Further checks using parameters stored in the protection block are also made to ensure that the command is valid, and if all checks are passed, the I/O adapter translates the data pointer to the appropriate physical address, and the command executes.
The method of comparing two keys exactly, wherein the key corresponds uniquely to the appropriate hardware address, means that there is no possibility of conflicts occurring, unlike the system described in the Background of the Invention. Furthermore, since the key in the protection block is calculated directly from the physical address of the register in the I/O adapter, which is a hardware device, the method may be easily implemented in hardware with reduced processing overhead relative to alternative systems that have been suggested.
There is therefore provided, in accordance with a preferred embodiment of the present invention, a method for protecting addresses in a system memory from improper access in a computer system in which a software application accesses the system memory by communicating directly with a hardware device, including:
in an initialization stage:
assigning a register of the hardware device to the application;
generating in the hardware device a protection block, which block is used thereafter by the device to control access by the application to the system memory;
storing in the protection block a first key corresponding to a physical address of the register; and
assigning a handle to the application that refers to the protection block; and
in operation of the application:
conveying a command from the application via the register to access the system memory, the command including the handle;
responsive to the command, generating in the hardware device a second key corresponding to the physical address of the register;
responsive to the handle, comparing the first and second keys; and
allowing the application to access the system memory only if the first and second keys match in a predetermined manner.
Preferably, the system memory includes memory accessed via a computer network.
Preferably, assigning the register includes assigning the register uniquely to the application, among other applications and registers in the system.
Preferably, storing the first key includes storing a key unique to the system.
Preferably, comparing the first and second keys includes checking one or more access permissions held in the protection block.
Preferably, allowing the application to access the system memory includes utilizing a translation table associating virtual addresses used by the application with physical addresses in the system memory. Further preferably, utilizing the translation table includes storing a pointer to the translation table in the protection block.
Preferably, allowing the application to access the system memory includes allowing access only if the first and second keys match exactly.
There is further provided, in accordance with a preferred embodiment of the present invention, a method for protecting addresses in a system memory from improper access in a computer system in which a software application accesses the system memory by communicating directly with a pre-assigned register of a hardware device, the register having a predetermined physical address in the system, the method including:
conveying a command from the application via the register to access the system memory;
responsive to the command, generating in the hardware device a command key corresponding to the physical address of the register;
comparing the command key to a stored access key previously assigned to the application; and
allowing the application to access the system memory only if the keys match in a predetermined manner.
Preferably, the access key is stored in a protection block of the hardware device, and conveying the command includes conveying a handle assigned to the application that refers to the protection block.
Preferably, the stored access key corresponds to the physical address of the register.
Preferably, the system memory includes memory accessed via a computer network.
Preferably, the pre-assigned register is assigned uniquely to the application, among other applications and registers in the system.
Preferably, generating the command key includes generating a key unique to the system.
Preferably, comparing the command key and the stored access key includes checking one or more access permissions held in the protection block.
Preferably, allowing the application to access the system memory includes utilizing a translation table associating virtual addresses used by the application with physical addresses in the system memory.
Alternatively, utilizing the translation table includes storing a pointer to the translation table in the protection block.
Preferably, allowing the application to access the system memory includes allowing access only if the command and access keys match exactly.
There is further provided, in accordance with a preferred embodiment of the present invention, an input/output adapter for communicating directly with a software application running in a computer system so as to enable the application to access a system memory in the system while protecting addresses in the system memory from improper access, the adapter including:
a register having a physical address, which responsive to a command from the application to access the system memory generates a command key corresponding to the physical address of the register; and
a protection block, which stores an access key assigned to the application, and which compares the command key and the access keys and enables the application to access the system memory only if the keys match in a predetermined manner.
Preferably, the protection block includes a handle which is used by the application to refer to the protection block.
Preferably, the system memory includes memory accessed via a computer network.
Preferably, the register is assigned uniquely to the application, among other applications and registers in the system.
Preferably, the command key includes a key unique to the system.
Preferably, the protection block holds one or more access permissions which are compared to enable the application to access the system memory.
Preferably, the protection block accesses a translation table associating virtual addresses used by the application with physical addresses in the system memory.
Alternatively, the protection block stores a pointer to the translation table.
Preferably, the application accesses the system memory only if the command and access keys match exactly.
There is further provided, in accordance with a preferred embodiment of the present invention, a computer program product for use in a computer system so as to enable a software application to access a system memory by communicating directly with a hardware device while protecting addresses in the system memory from improper access, the product preferably comprising a computer-readable medium having computer-readable program instructions embodied therein, which instructions, when executed by the computer system, cause the system to assign a register of the hardware device to the application, and to generate in the hardware device a protection block, which block is used thereafter by the device to control access by the application to the system memory, and to store in the protection block a first key corresponding to a physical address of the register and assign a handle to the application that refers to the protection block,
so that in operation of the application, when a command including the handle is conveyed from the application via the register to access the system memory, a second key is generated in the hardware device responsive to the command, corresponding to the physical address of the register, and wherein responsive to the handle, the first and second keys are compared, and the application is allowed to access the system memory only if the keys match in a predetermined manner.
There is further provided, in accordance with a preferred embodiment of the present invention, a computer program product for use in a computer system in which a software application accesses a system memory by communicating directly with a pre-assigned register of a hardware device, the register having a predetermined physical address in the system, the product preferably comprising a computer-readable medium having computer-readable program instructions embodied therein, which instructions, when executed by the computer system, cause the system to protect addresses in the system memory from improper access by conveying a command from the application via the register to access the system memory and, responsive to the command, generating in the hardware device a command key corresponding to the physical address of the register, and by comparing the command key to a stored access key previously assigned to the application, so as to allow the application to access the system memory only if the keys match in a predetermined manner.
The present invention will be more fully understood from the following detailed description of the preferred embodiment thereof, taken together with the drawings, in which: